/**
 * Created by dukes on 2015/12/23.
 */
class ActivityInfo {
    public config:any[];
    public desc:string;
    public endTime:number;
    public hidden:boolean;
    public id:number;
    public name:string;
    public showEndTime:number;
    public showStartTime:number;
    public startTime:number;
    public verifyId:number;

    public constructor(data:any=null){
        //super();
        if( data )
            this.initFromData(data);
    }

    public initFromData(data:any){
        this.config = [];
        var list = JSON.parse(data.config);
        var info;
        this.id = data.id;
        if( this.id == ActivityMgr.ACTIVITY_MONEY_CAT){
            for(var key in list.map){
                info = list.map[key];
                this.config[parseInt(key)-1] = new MoneyCatAcitivityConfig(info);
            }
        }else if( this.id == ActivityMgr.ACTIVITY_RECHARGE){
            for(var key in list.types){
                info = list.types[key];
                this.config[parseInt(key)-1] = new RechargeActivityConfig(info);
            }
        }else if( this.id == ActivityMgr.ACTIVITY_BATH){
            for(var key in list.map){
                info = list.map[key];
                this.config[parseInt(key)] = new BathConfig(info);
            }
        }else {
            this.config.push(list);
        }

        this.desc = data.desc;
        this.endTime = data.endTime;
        this.hidden = data.hidden;

        this.name = data.name;
        this.showEndTime = data.showEndTime;
        this.showStartTime = data.showStartTime;
        this.startTime = data.startTime;
        this.verifyId = data.verifyId;
    }
}